package com.antler.smt.portal.controller;

import com.antler.smt.request.portal.QuestionReq;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.portal.SourceService;
import com.antler.smt.validate.DataValidator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 说明来源
 *
 * @author zhangyi
 * @date 2018/9/25 10:54
 */
@Controller
@Api(description = "用户提交知情来源")
public class SourceController extends BaseController{

    @Resource
    private SourceService sourceService;

    @RequestMapping(value = "/source",method = RequestMethod.POST)
    @ApiOperation(value = "直接将选择字符串插入，用户,号将各个标签隔开",httpMethod = "POST")
    @ResponseBody
    public Result source(String source){
        QuestionReq questionReq = new QuestionReq();
        questionReq.setMemberid(currentMember.getId());
        questionReq.setSource(source);

        DataValidator.isBlank(source,"来源不能为空！");
        DataValidator.isBlank(String.valueOf(currentMember.getId()),"用户id不能为空！");

        return sourceService.addSources(questionReq);
    }
}
